package com.example.mask.maskmobilesshop.service.impl;

import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.baomidou.mybatisplus.service.impl.ServiceImpl;
import com.example.mask.maskmobilesshop.entity.Address;
import com.example.mask.maskmobilesshop.mappers.AddressMapper;
import com.example.mask.maskmobilesshop.service.AddressService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;

@Service
public class IAddressService extends ServiceImpl<AddressMapper, Address> implements AddressService {

    @Autowired
    private AddressMapper addressMapper;


    @Override
    public List<Address> findByMemberId(Long memberId) throws Exception {
        try {
            List<Address> result = addressMapper.selectList(new EntityWrapper<Address>().eq("member_id", memberId));
            return result;
        } catch (Exception e) {
            throw new Exception(e.getMessage());
        }
    }



    @Override
    public void updateDefaultAddress(Map<String, Object> params) {
        try {
            addressMapper.updateDefaultAddress(params);

        }catch (Exception e){
            e.printStackTrace();

        }
    }
}
